<template>
  <el-drawer direction="rtl"  :title="dialogTitle" v-model="dialogVisible" size="1200px">
      <ContentWrap>
        <!-- 搜索工作栏 -->
        <el-form
          class="-mb-15px"
          :model="queryParams"
          ref="queryFormRef"
          :inline="true"
          label-width="68px"
        >
          <el-form-item label="" prop="account">
            <el-input placeholder="请输入内容" v-model.trim="queryParams.account"/>
          </el-form-item>
          <el-form-item>
            <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
          </el-form-item>
        </el-form>
      </ContentWrap>

      <!-- 列表 -->
      <ContentWrap>
        <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
          <el-table-column label="编号" align="center" prop="id" width="60"/>
          <el-table-column label="账号" align="left" prop="account" width="120"/>
          <!-- <el-table-column label="密码" align="center" prop="passWord" width="80"/> -->
          <el-table-column label="套餐名称" align="left" prop="serverName" width="210"/>
          <!-- <el-table-column label="价格" align="left" prop="serverPrice" width="60"/> -->
          <el-table-column label="地址" align="left" prop="addrRemark" min-width="300"/>
          <el-table-column label="充值前有效期" align="left" width="220">
            <template #default="scope">
              <div>{{ formatDate(scope.row.oldNetExpiresTime) }}</div>
            </template>
          </el-table-column>
          <el-table-column label="有效期（计费系统）" align="left" width="150">
            <template #default="scope">
              <div>{{ formatDate(scope.row.expireTime) }}</div>
            </template>
          </el-table-column>
        </el-table>

        <!-- 分页 -->
        <Pagination
          :total="total"
          v-model:page="queryParams.pageNo"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </ContentWrap>
  </el-drawer>
</template>

<script setup lang="ts">
import { formatDate } from '@/utils/formatTime'
import { getNetGroupPayAccountLogPage } from '@/api/zwsj/netGroupPayOrder'

/** 宽带账号分账 列表 */
defineOptions({ name: 'NetGroupPayAccountLog' })

const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题

const loading = ref(true) // 列表的加载中
const list = ref([]) // 列表的数据
// 列表的总页数
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  groupPayOrderId: 0,
  account: '',
})

/** 打开弹窗 */
const open = async (groupPayOrderId: number) => {
  dialogVisible.value = true
  dialogTitle.value = '充值明细'
  queryParams.groupPayOrderId = groupPayOrderId
  getList()
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await getNetGroupPayAccountLogPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}
</script>